<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>过滤器</title>
    <script src="https://unpkg.com/dayjs@1.8.21/dayjs.min.js"></script>
    <script src="vue.js"></script>
</head>
<body>
<div id="root">
    <h2>现在是：{{time|timeFormater}}</h2>
    <h2>现在是：{{time|myslice}}</h2>
    <h2 :x="msg|myslice"></h2>
    <h2></h2>
    <h2></h2>
</div>

</body>
<script type="text/javascript">
    //全局过滤器
    Vue.filter('myslice',function (value) {
        return value
    })
    const vm = new Vue({
        el:"#root",
        data:{
            time:1621561377603,
            msg:'你好，北京'
        },
        //局部过滤器
        filters:{
            timeFormater(val){
                return dayjs(val).format('YYYY MMMM DD HH:mm:ss')
            }
        }
    })



</script>
</html>